package com.hspedu.spring.bean;

import org.springframework.beans.BeansException;
import org.springframework.beans.factory.config.BeanPostProcessor;

/**
 * Created by Gening on 3/11/2025
 */



public class MyBeanPostProcessor implements BeanPostProcessor {
    @Override
    public Object postProcessBeforeInitialization(Object bean, String beanName) throws BeansException {
        System.out.println("postProcessBeforeInitialization is called "+"and the bean=>"+bean+"\t\n"+" the beanName is " + beanName);

        if(bean instanceof House){
            ((House)bean).setName("the big House in Madison");
        }

        return bean;
    }

    @Override
    public Object postProcessAfterInitialization(Object bean, String beanName) throws BeansException {
        System.out.println("postProcessAfterInitialization is called "+"and the bean=>"+bean+"\t\n"+" the beanName is " + beanName);
        return null;
    }
}
